$(function () {
    //点击头像 获取用户个人资料   可以封装成全局函数
    ziliao("#example5","ziliao.json");
    function ziliao(table,url){
        $(table).ajaxComplete(function(){  //意思是在重新加载完了之后再执行函数
            $(".userData").unbind("click").click(function(){   //避免请求多次
                var user_id = $(this).find("small").text(); //回去用户的 ID 传给后台
                console.log(user_id.substring(0,1)+"...."+parseInt(user_id.substring(1)))
                $(".usre_photos").html(null);  $(".user_setphotos").html(null); //初始化放相片的 div 为空
                $("#gallery-wrapper").empty();
                $.ajax({
                    type:"GET",
                    url:url,
                    async:true,
                    data:user_id,
                    success: function (data) {
                
                        $(".usre_photos").addClass("tag_show");$(".user_setphotos").removeClass("tag_show");
                        var _data = data.data;
                        //显示基本信息
                        $(".user_name").text(_data.name);$(".user_show-aout").text(_data.show_aotu);$(".user_ID").text(_data.Id);
                        $(".user_address").text(_data.address);$(".user_weight").text(_data.weight);$(".user_height").text(_data.height);
                        $(".user_phone").text(_data.phone);$(".user_WeChat").text(_data.WeChat);$(".user_level").text(_data.level);
                        $(".user_tag").text(_data.tag);$(".user_consumption").text(_data.consumption);$(".user_loginNum").text(_data.loginNum);
                        //显示对应的状态
                        if (_data.tag != "") {
                        	$(".zhuangtaikuang a:eq(0)").css({"background":"red"})
                        }
                        $(".zhuangtaikuang a:eq(7)").empty().append("发送消息<span style='display:none'>"+user_id+"</span><img style='display:none' src='"+_data.head_img+"' /><small style='display:none'>"+_data.name+"</small>")
                        //显示照片
                        $phopto = ""; $phopto1="";
                        var photos = _data.img.photo_img; 		var setphotos = _data.img.setphoto_img;
                        
                        $.each(photos, function(i) {

                            $phopto += "<article class='white-panel'><img src='"+photos[i].img_url+"' class='thumbnail gallerybox'></article>";

                        });

                        $("#gallery-wrapper").append($phopto);  //审核过的

                        $.each(setphotos, function(i) {
                            $phopto1 +=  "<article class='white-panel'><span style='color:red'>私密照片</span><img src='"+setphotos[i].img_url+"' class='thumbnail gallerybox'></article>";

                        });
                        $("#gallery-wrapper").append($phopto1);  //未通过 审核过的
                        //相册层显示
						$(".gallerybox").gallerybox({
									bgColor:"#ef4983",
									bgOpacity:0.7
						});
						$("#gallery-wrapper").pinterest_grid({
									no_columns: 5,
									padding_x: 10,
									padding_y: 10,
									margin_bottom: 50,
									single_column_breakpoint: 700
						});
                        //显示信用资料
                        $(".xinyongzhil").click(function(){
                            $(".Ztouxian img").attr("src",_data.head_img);$(".Zlian img").attr("src",_data.face_img);
                            $(".Zshipin video").attr("src",_data.vadeo_url);
                            aplayer("ap22","贵觅","语音认证",_data.voice_url,"img/head/2014.jpg", 'player25','#myModal501');
                            var sfphopot = _data.idcard; var ziyphot=_data.professional;
                            $(".sf1").attr("src",sfphopot[0]);$(".sf2").attr("src",sfphopot[1]);
                            $(".ziy1").attr("src",ziyphot[0]);$(".ziy2").attr("src",ziyphot[1]);
                        });
                    },
                    error: function () {
                        swal("请求失败");
                    }
                });
            })

        })
    }

})



